import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/task/base_danger_investigation_info_entity.dart';

/// 隐患治理详情
class DangerControlDetailsController extends GetxController {
  /// 隐患id
  late String id;

  /// 接口上传的详情实体
  BaseDangerInvestigationInfoEntity infoEntity = BaseDangerInvestigationInfoEntity();

  /// 允许element在树周围移动(改变父节点), 而不会丢失状态
  final GlobalKey<ScaffoldState> videoKey = GlobalKey();

  /// 是否是展开状态
  bool isExpanded = false;

  /// 点击展开或者收起
  void onExpanded() {
    isExpanded = !isExpanded;
    update();
  }

  @override
  void onInit() {
    super.onInit();
    id = Get.arguments as String;
    _getLedgerDetail();
  }

  /// 查询隐患治理详情
  Future<void> _getLedgerDetail() async {
    final res = await HttpUtil().generateGetRequest<BaseDangerInvestigationInfoEntity>(Interface.getLedgerDetail, queryParameters: {'id': id}).execute();
    res.onSuccess((result) {
      if (result.data != null) {
        infoEntity = result.data!;
        update();
      }
    });
  }
}
